import { Controller, Get, Post, Body, Query } from '@nestjs/common'
import { SubjectsService } from './subjects.service'
import { CreateSubjectDto } from './dto/create-subject.dto'
import { GenerateShijuanDto } from './dto/generate-shijuan.dto'
// import { UpdateSubjectDto } from './dto/update-subject.dto'

@Controller('subjects')
export class SubjectsController {
  constructor(private readonly subjectsService: SubjectsService) {}

  @Post()
  create(@Body() createSubjectDto: CreateSubjectDto) {
    return this.subjectsService.create(createSubjectDto)
  }

  @Post('generate')
  async findAll(@Body() name: GenerateShijuanDto) {
    return await this.subjectsService.findRandomSubjects(name)
  }

  @Get('shijuan')
  async getShijuan(@Query() query: { subjectId: string }) {
    // console.log('subjectId', subjectId)
    return await this.subjectsService.getShijuan(query.subjectId)
  }
}
